/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class SearchInsideExcerpt
    {
    
        private String checksumField;

        private String pageTypeField;

        private String pageNumberField;

        private String sequenceNumberField;

        private String textField;


        /// <summary>
        /// Gets and sets the Checksum property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Checksum")]
        public String Checksum
        {
            get { return this.checksumField ; }
            set { this.checksumField= value; }
        }



        /// <summary>
        /// Sets the Checksum property
        /// </summary>
        /// <param name="checksum">Checksum property</param>
        /// <returns>this instance</returns>
        public SearchInsideExcerpt WithChecksum(String checksum)
        {
            this.checksumField = checksum;
            return this;
        }



        /// <summary>
        /// Checks if Checksum property is set
        /// </summary>
        /// <returns>true if Checksum property is set</returns>
        public Boolean IsSetChecksum()
        {
            return  this.checksumField != null;

        }


        /// <summary>
        /// Gets and sets the PageType property.
        /// </summary>
        [XmlElementAttribute(ElementName = "PageType")]
        public String PageType
        {
            get { return this.pageTypeField ; }
            set { this.pageTypeField= value; }
        }



        /// <summary>
        /// Sets the PageType property
        /// </summary>
        /// <param name="pageType">PageType property</param>
        /// <returns>this instance</returns>
        public SearchInsideExcerpt WithPageType(String pageType)
        {
            this.pageTypeField = pageType;
            return this;
        }



        /// <summary>
        /// Checks if PageType property is set
        /// </summary>
        /// <returns>true if PageType property is set</returns>
        public Boolean IsSetPageType()
        {
            return  this.pageTypeField != null;

        }


        /// <summary>
        /// Gets and sets the PageNumber property.
        /// </summary>
        [XmlElementAttribute(ElementName = "PageNumber")]
        public String PageNumber
        {
            get { return this.pageNumberField ; }
            set { this.pageNumberField= value; }
        }



        /// <summary>
        /// Sets the PageNumber property
        /// </summary>
        /// <param name="pageNumber">PageNumber property</param>
        /// <returns>this instance</returns>
        public SearchInsideExcerpt WithPageNumber(String pageNumber)
        {
            this.pageNumberField = pageNumber;
            return this;
        }



        /// <summary>
        /// Checks if PageNumber property is set
        /// </summary>
        /// <returns>true if PageNumber property is set</returns>
        public Boolean IsSetPageNumber()
        {
            return  this.pageNumberField != null;

        }


        /// <summary>
        /// Gets and sets the SequenceNumber property.
        /// </summary>
        [XmlElementAttribute(ElementName = "SequenceNumber")]
        public String SequenceNumber
        {
            get { return this.sequenceNumberField ; }
            set { this.sequenceNumberField= value; }
        }



        /// <summary>
        /// Sets the SequenceNumber property
        /// </summary>
        /// <param name="sequenceNumber">SequenceNumber property</param>
        /// <returns>this instance</returns>
        public SearchInsideExcerpt WithSequenceNumber(String sequenceNumber)
        {
            this.sequenceNumberField = sequenceNumber;
            return this;
        }



        /// <summary>
        /// Checks if SequenceNumber property is set
        /// </summary>
        /// <returns>true if SequenceNumber property is set</returns>
        public Boolean IsSetSequenceNumber()
        {
            return  this.sequenceNumberField != null;

        }


        /// <summary>
        /// Gets and sets the Text property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Text")]
        public String Text
        {
            get { return this.textField ; }
            set { this.textField= value; }
        }



        /// <summary>
        /// Sets the Text property
        /// </summary>
        /// <param name="text">Text property</param>
        /// <returns>this instance</returns>
        public SearchInsideExcerpt WithText(String text)
        {
            this.textField = text;
            return this;
        }



        /// <summary>
        /// Checks if Text property is set
        /// </summary>
        /// <returns>true if Text property is set</returns>
        public Boolean IsSetText()
        {
            return  this.textField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetChecksum()) {
                xml.Append("<Checksum>");
                xml.Append(EscapeXML(this.Checksum));
                xml.Append("</Checksum>");
            }
            if (IsSetPageType()) {
                xml.Append("<PageType>");
                xml.Append(EscapeXML(this.PageType));
                xml.Append("</PageType>");
            }
            if (IsSetPageNumber()) {
                xml.Append("<PageNumber>");
                xml.Append(EscapeXML(this.PageNumber));
                xml.Append("</PageNumber>");
            }
            if (IsSetSequenceNumber()) {
                xml.Append("<SequenceNumber>");
                xml.Append(EscapeXML(this.SequenceNumber));
                xml.Append("</SequenceNumber>");
            }
            if (IsSetText()) {
                xml.Append("<Text>");
                xml.Append(EscapeXML(this.Text));
                xml.Append("</Text>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}